package cn.rslee.uaas.service;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Component;

import cn.rslee.uaas.entity.AccessPage;
import cn.rslee.uaas.repository.AccessPageRepository;
import cn.rslee.uaas.util.U;

/**
 * 描述：
 * 
 * <pre>HISTORY
 * ****************************************************************************
 *  ID   DATE                    PERSON          REASON
 *  1    2016年3月11日         rslee               Create
 * ****************************************************************************
 * </pre>
 * @author rslee
 * @since 1.0
 */
@Component("accessPageService")
public class AccessPageServiceImpl implements AccessPageService{

	@Resource
	private AccessPageRepository accessPageRepository;
	
	@Override
	public List<AccessPage> findAll() {
		return accessPageRepository.findAll();
	}

	@Override
	public AccessPage get(long id) {
		return accessPageRepository.findOne(id);
	}

	@Override
	public List<AccessPage> findVisited(String sysCode, String day) {
		return accessPageRepository.findByDaysAndSysCodeAndTypes(U.toDate(day), sysCode, AccessPage.PAGE_VISITED);
	}

	@Override
	public List<AccessPage> findReferer(String sysCode, String day) {
		return accessPageRepository.findByDaysAndSysCodeAndTypes(U.toDate(day), sysCode, AccessPage.PAGE_REFERER);
	}

}
